package com.example.utils;

import lombok.Data;

/**
 * @author zhy
 * @version 1.0.0
 * @ClassName ApiResult.java
 * @Description TODO
 * @createTime 2021年06月26日 16:59:00
 */
@Data
public class ApiResult<T> {

    public Integer code;
    public String msg;
    public T data;

    public ApiResult success(){
        this.code = ResultCode.SUCCESS.getCode();
        this.msg = ResultCode.SUCCESS.getDesc();
        return this;
    }

    public ApiResult success(T data){
        this.code = ResultCode.SUCCESS.getCode();
        this.msg = ResultCode.SUCCESS.getDesc();
        this.data = data;
        return this;
    }

    public ApiResult failure(){
        this.code = ResultCode.ERROR.getCode();
        this.msg = ResultCode.ERROR.getDesc();
        return this;
    }

    public ApiResult failure(T data){
        this.code = ResultCode.ERROR.getCode();
        this.msg = ResultCode.ERROR.getDesc();
        this.data = data;
        return this;
    }

}
